//package com.yasaka.stock.config;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
//import org.springframework.orm.jpa.JpaTransactionManager;
//import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
//import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
//import org.springframework.transaction.PlatformTransactionManager;
//import org.springframework.transaction.annotation.EnableTransactionManagement;
//
//import javax.persistence.EntityManagerFactory;
//import javax.sql.DataSource;
//import java.util.Properties;
//
///**
// * Created by zhangqian on 2017/7/27.
// */
//@Configuration
//@EnableTransactionManagement
//@EnableJpaRepositories(basePackages = {"com.yasaka.stock.repository"})
//public class JPARepositoryConfig {
//
//
//    private String showSql = "true";
//
//    private String dialect = "org.hibernate.dialect.MySQLDialect";
//
//    @Bean
//    @Autowired
//    public EntityManagerFactory entityManagerFactory(DataSource dataSource) {
//
//        HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
//        vendorAdapter.setGenerateDdl(true);
//
//        Properties jpaProperties = new Properties();
//        jpaProperties.setProperty("hibernate.show_sql", showSql);
//        jpaProperties.setProperty("hibernate.dialect", dialect);
//
//        LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
//        localContainerEntityManagerFactoryBean.setJpaVendorAdapter(vendorAdapter);
//        localContainerEntityManagerFactoryBean.setPackagesToScan("com.yasaka.stock");
//        localContainerEntityManagerFactoryBean.setDataSource(dataSource);
//        localContainerEntityManagerFactoryBean.setJpaProperties(jpaProperties);
//        localContainerEntityManagerFactoryBean.afterPropertiesSet();
//
//        return localContainerEntityManagerFactoryBean.getObject();
//    }
//
//    @Bean
//    @Autowired
//    public PlatformTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
//        JpaTransactionManager jpaTransactionManager = new JpaTransactionManager();
//        jpaTransactionManager.setEntityManagerFactory(entityManagerFactory);
//        return jpaTransactionManager;
//    }
//
//}
